package de.op.projectc.objects;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class Heli extends GameObject {

	public Heli(Texture texture, float x, float y) {
		super(texture, x, y);
	}
	
	public Heli(Texture texture, float x, float y, float width, float height) {
		super(texture, x, y, width, height);
	}

	@Override
	public void update(float delta) {
		//Kein Sinn warum X Achse
	    float accelX = Gdx.input.getAccelerometerX();
	    
	    this.velocity.x = -accelX * (Gdx.graphics.getWidth() / 3);
	    this.sprite.setRotation(accelX * 7f);
	    this.sprite.translate(velocity.x * delta, velocity.y * delta);
	    
	    if(this.sprite.getX() < 0)
	    	this.sprite.setX(0);
	    if(this.sprite.getX() > Gdx.graphics.getWidth() - this.sprite.getWidth())
	    	this.sprite.setX(Gdx.graphics.getWidth() - this.sprite.getWidth());
	}

	@Override
	public void render(SpriteBatch spriteBatch) {
		this.sprite.draw(spriteBatch);
	}
}
